<?php


namespace App\Utils;


class HtmlDom
{
    protected $html;

    /**
     * @var \DOMXPath $xpath
     */
    protected $xpath;

    public function __construct(string $html = '')
    {
        $this->html = new \DOMDocument();
        if ($html) {
            $this->load($html);
        }
    }

    public function load($html)
    {
        $this->html->loadHTML($html);
        $this->html->normalize();

        $this->xpath = new \DOMXPath($this->html);
    }


    public function query($reg)
    {
        return $this->xpath->query($reg);
    }

}